package com.nage.components.touch.menu;

import android.util.Log;

import com.nage.R;
import com.nage.components.touch.Touchable;
import com.nage.engine.GameGraphBuilder;
import com.nage.engine.GameObject;
import com.nage.engine.Main;
import com.nage.input.InputSystem;

public class StartSinglePlayer extends Touchable {

	public StartSinglePlayer(GameObject p) {
		super(p);
		type = START_SINGLE_PLAYER;
	} 

	@Override
	public void onTouch() {
		Main.engine.endCurrentSimulation();
		InputSystem.clearResponders();
		Main.engine.initSimulationSystem(GameGraphBuilder.load(Main.engine.context.getResources().getXml(R.xml.singleplayer), Main.engine.context));
		try {
			Main.engine.linkSystems();
		} catch (Exception e) {
			Log.e("StartSinglePlayer", "Cannot start new single player game: "+e.getMessage());
		}
	}

}
